package com.zlf.mapper;

import com.zlf.entity.RoleEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zlf.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author zhanglongfei
 * @since 2021-05-24
 */
@Mapper
public interface RoleMapper extends BaseMapper<RoleEntity> {

    /*
    根据用户id查询用户的角色
     */
    @Select("select r.id, r.name from t_role r left join t_user_role ur on ur.role_id = r.id where ur.user_id = #{userId}")
    List<RoleEntity> getRolesByUserId(Integer userId);

}
